/************************************************************************

								Heroes IV
					  Copyright 2000, The 3DO Company

	------------------------------------------------------------------
  						       quicksand.h

	$Header: /game/quicksand.h $

	$NoKeywords: $

 ************************************************************************/

#ifndef QUICKSAND_H_INCLUDED
#define QUICKSAND_H_INCLUDED

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "combat_actor.h"
#include "combat_spell.h"
#include "map_point_list.h"
#include "mouse_window_ptr.h"

// --------------------------------------------------------------
// quicksand object
// --------------------------------------------------------------
class t_quicksand : public t_combat_actor
{
public:
	t_quicksand( t_battlefield& battlefield );

	virtual t_combat_object_type	get_object_type() const;
	virtual bool					is_quicksand() const;
	virtual bool					is_underlay() const;
	virtual void					on_placed();
	virtual void					on_removed();
	virtual bool					read( t_combat_reader& reader );
protected:
	t_battlefield& m_battlefield;
};

typedef t_counted_ptr<t_quicksand> t_quicksand_ptr;

// --------------------------------------------------------------
// quicksand spell
// --------------------------------------------------------------
class t_quicksand_spell : public t_combat_spell
{
public:
	t_quicksand_spell( t_battlefield& battlefield, t_spell spell);

	virtual bool            begin_casting();
	virtual bool		    can_cast( t_screen_point const& point ) const;
	virtual void            execute( t_combat_creature& caster );
	virtual t_combat_ai_action_list generate_combat_ai_action_list(t_combat_ai &owner);
	virtual double					get_cancel_weight( t_combat_creature const& target ) const;
	virtual t_mouse_window* mouse_move( t_screen_point const& point,
									    std::string& help_text );
	virtual bool            left_click( t_screen_point const& point );
protected:
	bool can_cast( t_map_point_2d const& point ) const;
	int  count_squares( t_map_point_2d const& point ) const;
	void eliminate_extra_points();
	bool get_map_point( t_screen_point const& screen_point, 
		                t_map_point_2d& map_point ) const;
	bool is_covered( t_map_point_2d const& point ) const;

	bool		        m_dragging;
	int				    m_covered;
	t_screen_point		m_last_point;
	t_quicksand_ptr		m_quicksand;
	t_map_point_2d_list m_targets;
	t_mouse_window_ptr  m_bucket_cursor;
};

#endif // QUICKSAND_H_INCLUDED